{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Python \t\t3.6\n",
      "Tensorflow \t1.0.0\n"
     ]
    }
   ],
   "source": [
    "import sys; print('Python \\t\\t{0[0]}.{0[1]}'.format(sys.version_info))\n",
    "import tensorflow as tf; print('Tensorflow \\t{}'.format(tf.__version__))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%matplotlib inline \n",
    "\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Extracting ../mnist-data/train-images-idx3-ubyte.gz\n",
      "Extracting ../mnist-data/train-labels-idx1-ubyte.gz\n",
      "Extracting ../mnist-data/t10k-images-idx3-ubyte.gz\n",
      "Extracting ../mnist-data/t10k-labels-idx1-ubyte.gz\n"
     ]
    }
   ],
   "source": [
    "from tensorflow.examples.tutorials.mnist import input_data\n",
    "mnist = input_data.read_data_sets(\"../mnist-data/\", one_hot=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(55000, 784)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mnist.train.images.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA2oAAABpCAYAAABLV9A4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xec1MX9x/HXBIMKRiwUTywgNrALYkM0llA0lqgxihEC\nBh8xGCXBFjVRrImgxC62GBV/sUcRu2IhagAVC7agh4iIolGjRhT9/v7gPrOz7N6xtzu7+9279/Px\n8OEwe7c7+75t3535fsYlSYKIiIiIiIikx/eqPQARERERERHJpgM1ERERERGRlNGBmoiIiIiISMro\nQE1ERERERCRldKAmIiIiIiKSMjpQExERERERSRkdqImIiIiIiKRMSQdqzrmBzrnXnXP/ds6dFGtQ\nrZkyjU+ZlodyjU+ZxqdM41Om8SnT+JRpfMq08lyxG14759oAbwB7Ae8C04FDkySZHW94rYsyjU+Z\nlodyjU+ZxqdM41Om8SnT+JRpfMq0OlYo4Xf7Av9OkuQtAOfc/wH7AY3+wTp27Jh069athJtsuWbO\nnLkI2BdlGo0yjW/mzJmLkiTpRDOf/8q0cco0PmUaX7GZgnJtTH19PYsWLXIo06j03h+fMo0veE1t\nUikHal2BecG/3wW2X/aHnHMjgZEA6623HjNmzCjhJlsu59xclGlUyjS+hkyhgFyVaWGUaXzKNL7m\nZNrw88p1Ofr06WNNZRqR3vvjU6bxBa+pTSp7MZEkSSYmSdInSZI+nTot98BRCqBM41Om8SnT+JRp\nfMq0PJRrfMo0PmUanzKNq5QDtfnAusG/12nok+Ip0/iUaXko1/iUaXzKND5lGp8yjU+ZxqdMq6CU\nA7XpwEbOue7OubbAz4C74wyr1VKm8SnT8lCu8SnT+JRpfMo0PmUanzKNT5lWQdHnqCVJssQ5Nwp4\nAGgDXJskySvRRhbRGWec4dvXX389ALfccovvC9aJV1UtZVorlGl5KNf4lGl8yjQ+ZRqfMo1Pmcan\nTKujlGIiJEkyBZgSaSyCMi0HZVoeyjU+ZRqfMo1PmcanTONTpvEp08orezERERERERERaZ6SZtTS\nburUqQBceeWVvq99+/YAWeVC07L0UUREREREBDSjJiIiIiIikjotbkbtv//9r28ffPDBABxxxBG+\n709/+hMAzrnKDkxEas5dd90FwOjRo33fpEmTANhxxx2rMiYRadp3330HwI033uj7Xnklt+bBs88+\n69vbb7903962bdv6Pnvet2nTxvd16NAh7mBbmbvvXlok8NJLL/V9VtxN2Uo5rLfeejl977zzThVG\nUhzNqImIiIiIiKSMDtRERERERERSpsUtfbz88st9e6WVVgJgzJgxvm+FFVrcXa66N954A4ARI0b4\nvrffftu3bfnJxx9/7PvuvfdeAM477zzf16lTp7KOU6S57rjjDgDmzp3r++xxPnv27KqMSaS1C09x\nWLhwIQB/+ctffN9hhx0GwNChQ5u8nh122MG3J06cCEBdXZ3vmzZtGgCzZs3yfccddxwAxx9/vO+z\nzxqS3zPPPOPbw4YNA2CfffbxfSuuuGKlhyStyLx58wBYd911qzyS4mhGTUREREREJGVa3PSSFQsB\nOOqoo4Dsb8gkjldffdW3Bw0aBGSfnJkkiW8PGDAAgI022sj32WzEzJkzfd/DDz8MQMeOHcsw4vSy\nb4TXXHNN32czv4sXL/Z9H3zwQc7vPv7447793HPPNXobV111lW+vvfbaOZf/+c9/BmC//fYrdNit\nwvTp06s9hKr47LPPAPjDH/7g+8IZi6b8+Mc/9u2LL74YgPXXXz/i6KQ1+fzzz33b3jfOPPNM3zd5\n8uSc37nkkksA6Nu3r++zWba33nrL92222Wa+bbNrW265pe974oknADj88MN9n82yLViwwPddcMEF\ngGbWlnXfffcBcMUVV/i+//znPwCstdZavq+15vbRRx8Bmc8+AOPGjQOyt5AK/fa3vwVg/PjxZR5d\nbbMCNZB5btvztDnComFWoND+BpWiGTUREREREZGU0YGaiIiIiIhIyrSYpY92cvHXX3/t+3r27Fmt\n4bRYJ554IgCPPvqo77Mlj127dvV94TK+F198EYAjjzzS99mJ23YZwI9+9CMgs7QEYOWVV4429mqx\n+wrZSxzMY489BmRPsdtSEFsaEf5cKFxi2tTegOHPvfnmmzmX2xKftC99vPXWWwG4+eabfd9ZZ50F\nQK9evSoyBltC1dI89dRTvj1y5EgAXnvtNd+X7/G10047AfD666/7vnApmhURCJebrbLKKpFGXPss\nK3tcQ/Z7mAnzXXXVVYHsJf3nnHMOAN27dy/LOKspLNpje53lEz4+DzjgACB7r65wqV2h+vfvD8DA\ngQN932233QbAAw884Pt+97vfAdCjR49m30ZL87///c+3r776aiCzdxpk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qzJVpspUmSpT5apMW3amrmFAIiIiIiIi\nkhIqJiIiIiIiIpIyOlATERERERFJGR2oiYiIiIiIpIwO1ERERERERFJGB2oiIiIiIiIpowM1ERER\nERGRlNGBmoiIiIiISMr8PzT+1wrcrWcKAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x113950a58>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(15,5))\n",
    "for i in list(range(10)):\n",
    "    plt.subplot(1, 10, i+1)\n",
    "    pixels = mnist.test.images[i+100]\n",
    "    pixels = pixels.reshape((28, 28))\n",
    "    plt.imshow(pixels, cmap='gray_r')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hdf5 is not supported on this machine (please install/reinstall h5py for optimal experience)\n"
     ]
    }
   ],
   "source": [
    "import tflearn as tfl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Training Step: 8599  | total loss: \u001b[1m\u001b[32m0.22827\u001b[0m\u001b[0m | time: 4.102s\n",
      "| Adam | epoch: 010 | loss: 0.22827 - acc: 0.9337 -- iter: 54976/55000\n",
      "Training Step: 8600  | total loss: \u001b[1m\u001b[32m0.23009\u001b[0m\u001b[0m | time: 5.154s\n",
      "| Adam | epoch: 010 | loss: 0.23009 - acc: 0.9357 | val_loss: 0.31634 - val_acc: 0.9225 -- iter: 55000/55000\n",
      "--\n"
     ]
    }
   ],
   "source": [
    "# Building slp network\n",
    "network = tfl.input_data(shape=[None, 784], name='input')\n",
    "network = tfl.fully_connected(network, 10, activation='softmax')\n",
    "network = tfl.regression(network, optimizer='adam', learning_rate=0.01,\n",
    "                     loss='categorical_crossentropy', name='target')\n",
    "\n",
    "# Training\n",
    "model = tfl.DNN(network, tensorboard_verbose=0, tensorboard_dir=\"./tensorboard/tfl\")\n",
    "model.fit({'input': mnist.train.images}, {'target': mnist.train.labels}, n_epoch=10,\n",
    "           validation_set=({'input': mnist.test.images}, {'target': mnist.test.labels}),\n",
    "           snapshot_step=500, show_metric=True, run_id='slp_mnist')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0.92249999999999999]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# evaluation\n",
    "model.evaluate(mnist.test.images, mnist.test.labels)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0: 2.397350726823788e-06,\n",
       " 1: 0.0007825364009477198,\n",
       " 2: 0.03597689047455788,\n",
       " 3: 0.00019160288502462208,\n",
       " 4: 1.4806926174060209e-06,\n",
       " 5: 3.931336323148571e-07,\n",
       " 6: 0.9630403518676758,\n",
       " 7: 3.8995090489990503e-10,\n",
       " 8: 4.15785689256154e-06,\n",
       " 9: 2.1142336947832518e-07}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# test item #100 is a \"six\"\n",
    "pixels = mnist.test.images[100]\n",
    "\n",
    "result = model.predict([pixels])\n",
    "dict(zip(range(10), result[0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def test_render(pixels, result, truth):\n",
    "    #pixels, result and truth are np vectors\n",
    "    plt.figure(figsize=(10,5))\n",
    "    plt.subplot(1, 2, 1)\n",
    "    pixels = pixels.reshape((28, 28))\n",
    "    plt.imshow(pixels, cmap='gray_r')\n",
    "\n",
    "    plt.subplot(1, 2, 2)\n",
    "    \n",
    "    #index, witdh\n",
    "    ind = np.arange(len(result))\n",
    "    width = 0.49\n",
    "\n",
    "    plt.barh(ind,result, width, color='orange', edgecolor='k', hatch=\"/\")\n",
    "    plt.barh(ind+width,truth,width, color='g', edgecolor='k')\n",
    "    plt.yticks(ind+width, range(10))\n",
    "    plt.margins(y=0)\n",
    "\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAlMAAAEyCAYAAADeAVWKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHGJJREFUeJzt3X2QVfWd5/HPhxaC0joB6bAMIJiIqWHdiaa6jKMY8Sml\nbErM7sTCJDM6Zdn+EURnk9113KR0x3Ir4+bBycOQEOPqjAZHEx/aWYxPo3GdMqyNsspDnLiMDyBC\nu04SWisq8N0/7kE7PXSf05x77+8c7vtV1UX3vV/O/fQV6Q/n4XccEQIAAMD+mZA6AAAAQJ1RpgAA\nAEqgTAEAAJRAmQIAACiBMgUAAFACZQoAAKAEyhQAAEAJlCkAAIASKFMAAAAlHJQ6AADUwSGHHBIL\nFixIHQNAG61du/a1iOjJmzO3kwGAfLaDvy+BzmJ7bUT05s1xmA8AAKAEyhSAjmX7MtvrbW+wfXnq\nPADqiTIFoCPZPkbSxZKOl/QRSZ+0fVTaVADqiDIFoFP9nqQ1EfFmROyS9FNJ/y5xJgA1RJkC0KnW\nSzrZ9uG2D5G0WNKcxJkA1BBLIwDoSBGxyfZfSHpA0huS1knaPXzGdp+kvgTxANQISyMAgCTb/03S\nloj4q1GeZ2kEoMMUXRqhrXumpk+fHvPmzWvnSwJIrOiidynY/kBE7LB9hBrnS52QOhOA+ilVpmyf\nJekvJXVJuiEivjLW/Lx58zQwMFDmJQHUjO0XU2cYw49tHy7pHUmfj4hfpg4EoH72u0zZ7pL0HUln\nStoi6Unb/RGxsVnhAKCVIuLk1BkA1F+Zq/mOl/R8RGyOiLcl3SZpSXNiAQAA1EOZMjVL0svDvt6S\nPQYAB5zu7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tX6O4Sts+Q9F8knRMRb7UpW1F538Ohko6R9KjtFySdIKm/QiehF/lv\nsEVSf0S8ExH/JOkf1ShXVVAk/0VqrKWniHhC0mQ11gisi6bfhYUyBQDvKXJ3huEr3P+hpL+P6izY\nl5vf9nGSvqdGkarSuTp7jfk9RMSvImJ6RMyLiHlqnPd1TkQMpIn7LxT5M3S3GnulZHu6Gof9Nrcz\n5BiK5H9J0umSZPv31ChTg21NWU6/pD/Oruo7QdKvyi5SzGE+AMhExC7byyTdr/fuzrDB9p9LGoiI\nfjVux/M3tp9X4yTXpekS/7aC+f+7pG5Jd2Tnzb8UEeckCz1Cwe+hsgrmv1/SJ2xvlLRb0n+MiErs\n3SyY/wuSvm/7T9U4Gf3CCv2D4rfuqJGd13WVpImSFBHfVeM8r8WSnpf0pqQ/Kf2aFfr+AQAAaofD\nfAAAACVQpgAAAEqgTAEAAJRAmQIAACiBMgUAAFACZQoAAKAEyhQAAEAJ/x8eEtQ+9kb7wQAAAABJ\nRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x11cd3a3c8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import random\n",
    "i = random.randint(0,mnist.test.images.shape[0])\n",
    "\n",
    "pixels = mnist.test.images[i]\n",
    "truth  = mnist.test.labels[i]\n",
    "result = model.predict([pixels])[0]\n",
    "\n",
    "test_render(pixels, result, truth)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
